# -*- coding:utf-8 -*-
"""
Created on May 2, 2011

@author: Lithuanian
"""


from problem_agent import ProblemAgent
from anytimeAlgorithms import AnytimeAstarGraphSearch, AnytimeRandRestBF
from manAndRatioHeuristic import mixedWithManSum
from problem_agent import NO_LIMIT


class Smith(ProblemAgent):
    
    def solve(self, problem_state, time_limit):
        height = problem_state.height
        width = problem_state.width
        robots = len(problem_state.robots)
        
        if height < 7 and width < 7 and robots < 4 and time_limit >= 40:
            algo = AnytimeAstarGraphSearch(0.7)
        else:
            algo = AnytimeRandRestBF()
        if time_limit == NO_LIMIT:
            time_limit = None
        return algo.find(problem_state, mixedWithManSum(0.9), time_limit)